import App from "./App"
import { Development,OnlineDevelopmentModeDetails } from "./components"
import setAttributes from "./utils/handlePlatform/setAttributes.js"
import ResponseDataHoc from "./utils/handlePlatform/ResponseDataHoc.js"
const { createRoot } = window.ReactDOM
const isEnvProduction = process.env.NODE_ENV === "production"
const onlineDevelopmentMode = process.env.REACT_APP_ONLINE_DEVELOPMENT_MODE === "true"
if (isEnvProduction || (onlineDevelopmentMode && !window.online_development_islocal)) {
  if (!window.CUSTOM_PLUGIN) {
    window.CUSTOM_PLUGIN = new Map()
  }
  window.CUSTOM_PLUGIN.set(process.env.CONFIG_JSON_ID, (dom, props, context, eventBus) => {
    props = setAttributes(dom, props)
    const HocApp = ResponseDataHoc({ props, context, eventBus })(App)
    const root = createRoot(dom)
    root.render(HocApp)
  })
} else if (onlineDevelopmentMode && window.online_development_islocal) {
  const root = createRoot(document.getElementById("root"))
  root.render(<OnlineDevelopmentModeDetails />)
} else {
  require("antd/dist/antd.min.css")
  const root = createRoot(document.getElementById("root"))
  root.render(<Development />)
}
